#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;

int l, n, ret = 0;
int a[20][20];
int h[20];
int lie[20];

bool check(int x) {
	return x >= 0 && x <= l;
}

void dfs(int gs) {
	for(int i = 1; i <= n; ++ i ) {
		if(lie[i] > l || h[i] > l) {
			return ;
		}
	}
	if(gs == n * (n - 1) + 1) {
		int t = 0;
		for(int i = 1; i <= n; ++ i ) {
			if(!check(l - lie[i])) {
				return ;
			}
			t += (l - lie[i]);
		}
		if(t == l)
		ret ++ ;
		return ;
	}
	int x = gs / n + 1;
	if(gs % n == 0) {
		x -- ;
	}
	int y = gs % n;
	if(y == 0) {
		y = n;
	}
	for(int i = 0; i <= l; ++ i ) {
		a[x][y] = i;
		h[x] += i;
		lie[y] += i;
		dfs(gs + 1);
		h[x] -= i;
		lie[y] -= i;
	}
}

signed main() {
	IOS;
	cin >> l >> n;
	dfs(1);
	cout << ret << endl;
	return 0;
}

